extern "C" { 
    #include "apue.h" 
}   
#include <stdio.h>

#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

/*
    off_t lseek(int fd, off_t offset, int whence);
*/
int main(int argc ,char** argv)
{    
    int file_fd=open("me.o",O_CREAT|O_WRONLY|O_TRUNC,S_IRWXU);
    if(file_fd<0)
    {
        err_quit("creat file err");
    }

    off_t l_seek =lseek(file_fd, 100, SEEK_SET);
    if(l_seek==-1)
    {
        err_quit("lseek at fd 0 is err");
    }
    char* buf="hello in lseek at 100";
    ssize_t len=write(file_fd,  buf,(size_t)strlen(buf));


    printf("lseek success \n");
}

// reallin@ubuntu:~/work/pan/apue/study/3-6-2$ hexdump me.o  -C
// 00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
// *
// 009c4400  68 65 6c 6c 6f 20 69 6e  20 6c 73 65 65 6b 20 61  |hello in lseek a|
// 009c4410  74 20 31 30 30                                    |t 100|
// 009c4415
// reallin@ubuntu:~/work/pan/apue/study/3-6-2$ ls -lh me.o 
// -rwx------ 1 reallin reallin 121 Nov 23 14:55 me.o


// 也可以使用od命令
// reallin@ubuntu:~/work/pan/apue/study/3-6-2$ od -c  me.o 
// 0000000  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
// *
// 47042000   h   e   l   l   o       i   n       l   s   e   e   k       a
// 47042020   t       1   0   0
// 47042025